<% @main_header = "#{link_to('Ptrack:', '/')} #{@project.name}" %>

<div id="info" class='column span-8 colborder '>
  <h3>Project Info:</h3>
  <strong>Description:</strong> <%= @project.description %><br />
  <strong>Contract Date:</strong> <%=  @project.contract_date.to_formatted_s(:long) unless @project.contract_date.nil? %><br />
  <strong>Start Date:</strong> <%= @project.start_date.to_formatted_s(:long) unless @project.start_date.nil? %><br />
  <strong>End Date:</strong> <%= @project.end_date ? @project.end_date.to_formatted_s(:long) : "<i>On Progress</i>" %><br />

  <% if current_user.is_admin %>

    <% unless @project.currency=='TL' #display actual earnings in project currency %>
      <strong>Currency Rate at Contract Date:</strong> <%= @project.currency_rate unless @project.currency_rate.nil? %><br />
      <strong>Project Fee:</strong> <%= format_number @project.fee %>&nbsp;<%= @project.currency %> <br />

    <%end%>
  <%end%>
<br/>
  <br/>
 <h3> Project Progress </h3>
</div>
<div id="latest_activity" class='column span-15 last' >
  <h3>Latest Activity:</h3>
  <% if @activity_logs.empty? %>
    No activities, yet.
  <% else %>
    <select size="8" name="act" id="act" style="font-size: small; width:100%">
      <% for actvty in @activity_logs %>
        <option value=""><%= actvty.description %></option>
      <% end %>
    </select>
  <% end %>
</div>
<div id="progress_chart" class='column span-24'>
  <table>
    <tr>
  
   <th>Phase</th>
      <th>Fee Weight % </th>
      <th>Total Time Spent (hours)</th>
      <th>Effort Weight <br>  %</th>
      <th>Time Spent In Revision (hours)</th>
      <th>Revision Weight in Total Phase Effort % </th>
      <% if current_user.is_admin %>
        <th>Expected Earnings  <br> (<%= @project.currency %>)</th>
        <% unless @project.currency=='TL' #display actual earnings in project currency %>
          <th>Actual Earnings (<%= @project.currency %>)</th>
        <%end%>
        <th>Actual Earnings(TL)</th>
        <th>Actual Cost <br>(TL)</th>
        <th>Profit/Loss <br>(TL)</th>
        <th>Uncollected Amount <br>(<%=@project.currency%>)</th>
      <%end%>
    </tr>

<% for activity in @activities %>

      <tr class="<%= cycle('oddrow', 'evenrow') %>" >
        
        <td><%= link_to activity.phase.name, project_activity_url(@project,activity) %> </td>
        <td>  <%= activity.weight %> %</td>
        <td><%= activity.total_working_hours  %></td>
        <td><%= activity.percent_in_total_working_hours %> % </td>
        <td><%= activity.total_time_spent_for_revision %> </td>
        <td><%= activity.revision_percent_in_total_working_hours%> %</td>
        <% if current_user.is_admin %>
          <td><%= format_number activity.estimated_cost_in_project %></td>
          <% unless @project.currency=='TL' %>
            <td><%= format_number activity.collection_amount_total(true) %></td>
          <%end%>
          <td><%= format_number activity.collection_amount_total(false) %></td>
          <td><%= format_number activity.total_working_cost %> </td>
          <td><%= format_number activity.profit_loss  %></td>
          <td><%= format_number activity.uncollected_amount %></td>
        <%end%>
      </tr>
    <% end %>

    <th>Total</th>
    <th>100 %</th>
    <th><%=@project.total_working_hours%> </th>
    <th>100 %</th>
    <th><%=@project.total_revision_hours%> </th>
    <th><%=@project.revision_percent_in_total_working_hours_p %>  %</th>

    <% if current_user.is_admin %>
      <th><%= format_number @project.fee%> </th>
      <% unless @project.currency=='TL' %>
        <th><%= format_number @project.collection_amount_total(true) %> </th>
      <%end%>
      <th><%= format_number @project.collection_amount_total %> </th>
      <th><%=@project.total_working_cost_p%></th>
      <th><%=format_number @project.profit_loss_p%></th>
      <th><%=format_number @project.uncollected_amount%></th>
    <%end%>
  </table>
  <br />
  <%= link_to 'Back', projects_path %>
</div>


